/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package UserInterface;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;

/**
 *
 * @author Julien
 */
public class CommonWindow extends JFrame implements ActionListener{

    private JPanel north = new JPanel();
    private JPanel south = new JPanel();
    private JLabel titre = new JLabel("Application de gestion des notations");
    private JPanel panneauBoutons = new JPanel();

    private JButton deconnexion = new JButton("Deconnexion");
    private JButton accueil = new JButton("Accueil");
    private JButton gestionProfils = new JButton("Gestion des profils");
    private JButton gestionApogee = new JButton("Gestion Apogee");

    private JLabel jLabel2 = new JLabel();

    private JPanel conteneurTableau = new JPanel();

    /**
     * tableEcole est une arborescence permettant à l'utilisateur d'accéder aux à un élément particulier
     * de l'école tel qu'un département, une promotion ou une matiere.
     */
    private JTree tableEcole;

    public CommonWindow()
    {
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(900, 700);
        this.setTitle("Cyrene");

        this.initFrame();
    }

    public void initFrame() {

        this.setLayout(new BorderLayout());
        this.add(north, BorderLayout.NORTH);
        this.add(south, BorderLayout.CENTER);

        this.north.setLayout(new BorderLayout());
        this.south.setLayout(new BorderLayout());

        this.titre.setFont(new java.awt.Font("Tahoma", 0, 24));
        this.titre.setForeground(new java.awt.Color(0, 153, 153));
        this.titre.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        this.north.add(this.titre,BorderLayout.CENTER);
        this.north.add(this.jLabel2,BorderLayout.WEST);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("petitLogo.jpg")));

        initPanBoutons();


        this.south.add(this.panneauBoutons,BorderLayout.WEST);

        initArborescence();
        
        this.south.add(new JScrollPane(this.tableEcole),BorderLayout.CENTER);

        this.south.add(this.conteneurTableau,BorderLayout.EAST);

        this.pack();

    }


    public void initPanBoutons()
    {
           this.panneauBoutons.setLayout(new GridBagLayout());
           GridBagConstraints c = new GridBagConstraints();
           c.anchor = GridBagConstraints.WEST;
           c.insets = new Insets(0, 0, 0, 0);

           c.gridx = 0;
            c.gridy = 0;
           c.gridwidth = 1;
           c.gridheight = 1;
           c.weightx = 1;
           c.weighty = 1;

           this.panneauBoutons.add(this.deconnexion,c);
           this.deconnexion.addActionListener(this);

           c.gridx = 0;
            c.gridy = 1;
           

           this.panneauBoutons.add(this.accueil,c);
           this.accueil.addActionListener(this);

           c.gridx = 0;
            c.gridy = 2;

           this.panneauBoutons.add(this.gestionApogee,c);
           this.gestionApogee.addActionListener(this);

           c.gridx = 0;
            c.gridy = 3;

           this.panneauBoutons.add(this.gestionProfils,c);
           this.gestionProfils.addActionListener(this);

           this.deconnexion.setPreferredSize(this.gestionProfils.getPreferredSize());
           this.accueil.setPreferredSize(this.gestionProfils.getPreferredSize());
           this.gestionApogee.setPreferredSize(this.gestionProfils.getPreferredSize());

           this.panneauBoutons.setPreferredSize(new Dimension(150,100));
    }


    public void initArborescence()
    {
        DefaultMutableTreeNode racine = new DefaultMutableTreeNode("Polytech");
        this.tableEcole = new JTree(racine);
       // this.tableEcole.setPreferredSize(new Dimension(50,50));
        this.tableEcole.setMinimumSize(new Dimension(50,50));
    }

    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}


